# 页面类
from Base.Base import Base
from selenium.webdriver.common.by import By
import time
class Page(Base):
    search_loc = (By.XPATH, '//*[@id="chat-input-area"]')
    def search1(self):
        self.send_keys(self.search_loc, 'web自动化')
        self.Enter(self.search_loc)
    # 1.点击登录按钮
    login_loc=(By.NAME,'tj_login')
    def login(self):
        self.click(self.login_loc)
    # 2.输入用户名
    user_loc=(By.XPATH,'//input[contains(@id,"TANGRAM__PSP_11__userName")]')
    def user(self,username):
        self.send_keys(self.user_loc,username)
    # 3.输入密码
    passw_loc=(By.XPATH,'/html/body/div[9]/div[2]/div[2]/div/div/div/div/div/div[1]/div[2]/form/p[4]/input[2]')
    def passw(self,password):
        self.send_keys(self.passw_loc,password)
    # 4.点击协议
    xieyi_loc=(By.NAME,'isAgree')
    def xieyi(self):
        self.click(self.xieyi_loc)
    # 5.点击登录按钮
    login1_loc=(By.XPATH,'//input[starts-with(@id,"TANGRAM__PSP_11__submit")]')
    def login1(self):
        self.click(self.login1_loc)
    #
    home_loc = (By.XPATH, '//*[@id="u"]/a[1]')

    def home(self):
        self.click(self.home_loc)
    # 6.搜索框搜索
    search11_loc=(By.NAME,'wd')
    def search(self):
        self.send_keys(self.search11_loc,'web自动化')
        self.Enter(self.search_loc)


    # 业务逻辑
    def luoji_01_login_search(self):
        self.open_url('https://www.baidu.com/')
        # 1.点击登录按钮
        self.login()
        # 2.输入用户名
        self.user()
        # 3.输入密码
        self.passw()
        time.sleep(3)
        # 4.点击协议
        self.xieyi()
        # 5.点击登录按钮
        self.login1()
        time.sleep(3)
        # 6.搜索框搜索
        self.search()
        time.sleep(5)